import request from '@/utils/request'

export const login = (username, password, platform, tenant) => {
  console.log('test接口', platform)
  var grant_type = 'password'
  var scope = 'server'
  return request({
    url: '/auth/oauth/token',
    headers: {
      'Authorization': 'Basic MTU1NDY5MjYxODAwNjo4ZWI0OWNiNDg3ZTI0NzI0OTdjZWZiNDdiNzFhY2E4Zg==',
      'TENANT_ID': tenant
    },
    method: 'post',
    params: { username, password, platform, grant_type, scope }
  })
}

export const sassLogin = (username, password, platform) => {
  var grant_type = 'password'
  var scope = 'server'
  return request({
    url: '/auth/oauth/token',
    headers: {
      'Authorization': 'Basic MTU1NDY5MjYxODAwNjo4ZWI0OWNiNDg3ZTI0NzI0OTdjZWZiNDdiNzFhY2E4Zg=='
    },
    method: 'post',
    params: { username, password, platform, grant_type, scope }
  })
}

export function getInfo() {
  return request({
    url: '/admin/user/info',
    method: 'get'
  })
}

export function getMenu() {
  return request({
    url: '/admin/menu/userMenu',
    method: 'get'
  })
}

export function sassGetMenu() {
  return request({
    url: '/admin/menu/userMenu',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/auth/token/logout',
    method: 'delete'
  })
}

export function editInfo(ruleForm) {
  return request({
    url: '/admin/user/edit',
    method: 'put',
    data: ruleForm
  })
}
// 编辑页获取用户详情
export function getEditInfo(id) {
  return request({
    url: '/admin/user/' + id,
    method: 'get'
  })
}
// 查询租户用户列表
export function getCompanyList(username) {
  return request({
    url: '/admin/index/tenant/list',
    method: 'get',
    params: { username: username }
  })
}
